package JdbcTemplate.Lambda;

public class Test {

    //创建接口1
    interface Calculate1{
        int operation(int a,int b);
    }
    //创建接口2
    interface Calculate2{
        void operation(String message);
    }
    //接口1测试方法
    public static int operate(int a,int b,Calculate1 calculate1){
        return calculate1.operation(a,b);
    }
    //接口2测试方法
    public static void operate1(String message,Calculate2 calculate2){
        calculate2.operation(message);
    }

    public static void main(String[] args) {

        // 类型声明
        Calculate1 test1=(int a,int b)->a+b;
        //不用类型声明
        Calculate1 test2=(a,b)->a*b;
        // 大括号中的返回语句
        Calculate1 test3=(a,b)->{return a/b;};
        // 没有大括号及返回语句
        Calculate1 test4=(a,b)->a%b;
        //不用括号
        Calculate2 test5=message-> System.out.println(message);
        //用括号
        Calculate2 test6=(message)-> System.out.println(message+"world");

        System.out.println(operate(1,3,test1));
        System.out.println(operate(4,3,test2));
        System.out.println(operate(10,2,test3));
        System.out.println(operate(100,32,test4));
        operate1("hello",test5);
        operate1("hello",test6);

    }
}
